package me.xuym.crawler.dygang.entity;

import com.google.gson.Gson;
import me.xuym.crawler.simpleextension.dispatcher.SimpleDebugDispatcherInput;
import me.xuym.crawler.simpleextension.filter.SimpleCachedFilterInput;

import java.util.Hashtable;
import java.util.Map;

/**
 * Created by broche on 13/09/2017.
 */
public class DYGangWebResult extends DYGangResult implements SimpleCachedFilterInput, SimpleDebugDispatcherInput {
    @Override
    public Map<String, String> simpleCachedFilterCheckFields() {
        Map<String, String> fields = new Hashtable<>();
        fields.put("url", getUrl());
        return fields;
    }

    @Override
    public Map<String, String> simpleCachedFilterSaveFields() {
        Map<String, String> fields = new Hashtable<>();
        fields.put("name", getName());
        fields.put("url", getUrl());
        fields.put("createtime", getCreatetime() + "");
        return fields;
    }

    @Override
    public String simpleDebugDispatcherContent() {
        return new Gson().toJson(this);
    }
}
